{layout "../Layout/layout.latte"}
{block tabs_content}
    {*{include "./tabs.latte"}*}
{/block}
{block private_js}
    <script type="text/javascript">
        $(function () {
            $("#bnt").click(function () {
                $.ajax({
                    type: "post",
                    url: $("#formArticle").attr("action"),
                    data: $("#formArticle").serialize(),
                    cache: false,
                    dataType: "json",
                    success: function (data) {
                        console.log(data);
                        if (data.status == "n") {
                            $.toast(data.info);
                            return false;
                        } else {
                            $.toast(data.info);
                            setTimeout(function () {
                                $.showPreloader();
                                location.replace(data.url);
                            }, 1000);
                        }
                    }
                });
            })


            $(document).on('click', '.operate', function () {
                var id = $(this).attr("data-id");
                // alert(id)
                var buttons1 = [
                    {
                        text: '请选择',
                        label: true
                    },
                    {
                        text: '编辑',
                        bold: true,
                        onClick: function () {
                            location.replace("/modifyGroup?id=" + id)
                        }
                    },
                    {
                        text: '删除',
                        color: 'danger',
                        onClick: function () {
                            $.confirm('是否确认删除?', function () {
                                var formData = Object();
                                formData.id = id;
                                $.ajax({
                                    type: "post",
                                    url: "/delGroup",
                                    data: formData,
                                    cache: false,
                                    dataType: "json",
                                    success: function (data) {
                                        console.log(data);
                                        if (data.status == "n") {
                                            $.toast(data.info);
                                            return false;
                                        } else {
                                            $.toast(data.info);
                                            setTimeout(function () {
                                                location.replace(data.url);
                                            }, 1000);
                                        }
                                    }
                                });
                            });
                        }
                    }
                ];
                var buttons2 = [
                    {
                        text: '取消',
                        bg: 'danger'
                    }
                ];
                var groups = [buttons1, buttons2];
                $.actions(groups);
            });


        });

        function addGroup() {
            location.replace({url('mobileConsoles_company_AddGroup')});
        }

        function goback() {
            location.replace({url("mobileConsoles_user_company")})
        }
    </script>
{/block}
{block private_css}
    <style>
        .item-title, input{ font-size:0.9rem !important; }

        .list-block .item-content{ line-height:2rem; }
    </style>
{/block}
{block content}
    <form id="formArticle" class="stdform mform" method="post" action="" onsubmit="return false">
        <input type="hidden" name="userid" value="{$userid}">
        <input type="hidden" name="sid" value="{$sid}">
        <div class="list-block">
            <ul>
                {foreach $groupLists as $k=>$v}
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-name"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">{$v['names']}</div>
                                <div class="item-input" style="text-align: right;">
                                    <span class="operate" data-id="{$v['id']}">操作</span>
                                </div>
                            </div>
                        </div>
                    </li>
                {/foreach}
            </ul>
        </div>
    </form>
    <div class="content-block">
        <div class="col-95">
            <div class="button button-big button-fill" onclick="addGroup()">添加小组</div>
        </div>
    </div>
    <div class="content-block">
        <div class="col-95">
            <a onclick="goback()" style="text-align: center;display: block;">返回</a>
        </div>
    </div>
{/block}